﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace ComicsEditor
{
    public class Instrument : PageObject
    {
        protected PageInfo pageInfo;

        public Instrument() : base(null)
        {
            visible = false;
        }

        public virtual void Bind(PageInfo PageInfo)
        {
            bool enabled = false;
            if (page != null)
            {
                enabled = Page.Instrument == this;
                if (enabled)
                    Disable();
                page.Remove(this);
            }
            pageInfo = PageInfo;
            page = PageInfo.Page;
            Page.Add(this);
            if (enabled)
                Enable();
        }

        public virtual void Enable()
        {
            if (Page.Instrument != null)
                Page.Instrument.Disable();
            Page.Instrument = this;
        }

        public virtual void Disable()
        {
            Page.Instrument = null;
        }
    }
}
